#!/bin/bash

# LIMPIEZA CONFIGURACION PREVIA
./limpiezaInterfaces.sh

# ACTIVACION DE LA FUNCION DE ROUTER DEL SO
echo "1" >> /proc/sys/net/ipv4/ip_forward

# MASCARAS DE RED
Netmask24="255.255.255.0"
Netmask25="255.255.255.128"
Netmask26="255.255.255.192"
Netmask27="255.255.255.224"
Netmask28="255.255.255.240"
Netmask29="255.255.255.248"
Netmask30="255.255.255.252"

# INTERFACES
interfaz1=`ifconfig | egrep "eth." -o | head -1`
interfaz2=$interfaz1":0"
interfaz3=$interfaz1":1"
interfaz4=$interfaz1":2"
interfaz5=$interfaz1":3"

# IPS
IP1="10.74.63.242"
IP2="192.168.53.3"
IP3="10.74.63.225"
IP4="10.74.63.194"
IP5="10.74.63.2"

# DIRECCIONES DE BROADCAST
BR1="10.74.63.243"
BR2="192.168.53.255"
BR3="10.74.63.231"
BR4="10.74.63.223"
BR5="10.74.63.127"

# DIRECCIONES DE RED
#sanAntonio="10.74.63.0"
#lasConchas="10.74.63.192"
#calchaqui="10.74.63.224"
uruguay="192.168.53.0"
acaraguay="10.31.17.0"
chirimay="10.31.17.128"
uruguari="10.31.17.64"
iguazu="10.97.5.0"
gualeguay="10.74.57.0"
hernandarias="10.74.63.128"
#bululu="10.74.63.240"
nogoya="10.74.63.244"

# DIRECCIONES DE GATEWAY
porH124="10.74.63.241" #interfaz1


# CONFIGURACION DE LAS INTERFACES DEL ROUTER
ifconfig $interfaz1 $IP1 broadcast $BR1 netmask $Netmask30 pointopoint $porH124
ifconfig $interfaz2 $IP2 broadcast $BR2 netmask $Netmask24
ifconfig $interfaz3 $IP3 broadcast $BR3 netmask $Netmask29
ifconfig $interfaz4 $IP4 broadcast $BR4 netmask $Netmask27
ifconfig $interfaz5 $IP5 broadcast $BR5 netmask $Netmask25


# CONFIGURACION DE LA TABLA DE RUTEO
route add -net $acaraguay netmask $Netmask26 dev $interfaz1 metric 5 gw $porH124
route add -net $chirimay netmask $Netmask25 dev $interfaz1 metric 3 gw $porH124
route add -net $uruguari netmask $Netmask27 dev $interfaz1 metric 4 gw $porH124
route add -net $uruguay netmask $Netmask24 dev $interfaz2
route add -net $iguazu netmask $Netmask24 dev $interfaz1 metric 4 gw $porH124
route add -net $gualeguay netmask $Netmask24 dev $interfaz1 metric 1 gw $porH124
route add -net $hernandarias netmask $Netmask26 dev $interfaz1 metric 1 gw $porH124
route add -net $nogoya netmask $Netmask30 dev $interfaz1 metric 2 gw $porH124

